<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>移动端 | Ametshy_blog</title>
    <meta name="generator" content="VuePress 1.8.2">
    <link rel="icon" href="/my_blog/favicon.ico">
    <meta name="description" content="优秀的人如温玉，光华敛于内而不形于外。">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/my_blog/assets/css/0.styles.95786cb5.css" as="style"><link rel="preload" href="/my_blog/assets/js/app.cff69041.js" as="script"><link rel="preload" href="/my_blog/assets/js/3.7a043b16.js" as="script"><link rel="preload" href="/my_blog/assets/js/1.c06040f4.js" as="script"><link rel="preload" href="/my_blog/assets/js/16.a086f842.js" as="script"><link rel="prefetch" href="/my_blog/assets/js/10.59944bfc.js"><link rel="prefetch" href="/my_blog/assets/js/11.fb77baad.js"><link rel="prefetch" href="/my_blog/assets/js/12.52311b30.js"><link rel="prefetch" href="/my_blog/assets/js/13.52369ac6.js"><link rel="prefetch" href="/my_blog/assets/js/14.b902e744.js"><link rel="prefetch" href="/my_blog/assets/js/15.4a0d7f91.js"><link rel="prefetch" href="/my_blog/assets/js/17.06159aba.js"><link rel="prefetch" href="/my_blog/assets/js/4.54a99e11.js"><link rel="prefetch" href="/my_blog/assets/js/5.5c893200.js"><link rel="prefetch" href="/my_blog/assets/js/6.d532c4e4.js"><link rel="prefetch" href="/my_blog/assets/js/7.f74d9027.js"><link rel="prefetch" href="/my_blog/assets/js/8.a07eb38b.js"><link rel="prefetch" href="/my_blog/assets/js/9.609694ba.js">
    <link rel="stylesheet" href="/my_blog/assets/css/0.styles.95786cb5.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container" data-v-3def6117><div data-v-3def6117><div id="loader-wrapper" class="loading-wrapper" data-v-2c578df8 data-v-3def6117 data-v-3def6117><div class="loader-main" data-v-2c578df8><div data-v-2c578df8></div><div data-v-2c578df8></div><div data-v-2c578df8></div><div data-v-2c578df8></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-70a509e9 data-v-3def6117 data-v-3def6117><h3 class="title" data-v-70a509e9 data-v-70a509e9>Ametshy_blog</h3> <p class="description" data-v-70a509e9 data-v-70a509e9>优秀的人如温玉，光华敛于内而不形于外。</p> <label id="box" class="inputBox" data-v-70a509e9 data-v-70a509e9><input type="password" value="" data-v-70a509e9> <span data-v-70a509e9>Konck! Knock!</span> <button data-v-70a509e9>OK</button></label> <div class="footer" data-v-70a509e9 data-v-70a509e9><span data-v-70a509e9><i class="iconfont reco-theme" data-v-70a509e9></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-70a509e9>vuePress-theme-reco</a></span> <span data-v-70a509e9><i class="iconfont reco-copyright" data-v-70a509e9></i> <a data-v-70a509e9><span data-v-70a509e9>fh</span>
            
          <!---->
          2021
        </a></span></div></div> <div class="hide" data-v-3def6117><header class="navbar" data-v-3def6117><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/my_blog/" class="home-link router-link-active"><img src="/my_blog/logo.png" alt="Ametshy_blog" class="logo"> <span class="site-name">Ametshy_blog</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/my_blog/" class="nav-link"><i class="iconfont reco-home"></i>
  首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      文章分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my_blog/categories/other/" class="nav-link"><i class="undefined"></i>
  other
</a></li><li class="dropdown-item"><!----> <a href="/my_blog/categories/font-end/" class="nav-link"><i class="undefined"></i>
  font-end
</a></li></ul></div></div><div class="nav-item"><a href="/my_blog/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/my_blog/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间轴
</a></div><div class="nav-item"><a href="/my_blog/docs/theme-reco/" class="nav-link router-link-active"><i class="iconfont reco-message"></i>
  文章列表
</a></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-3def6117></div> <aside class="sidebar" data-v-3def6117><div class="personal-info-wrapper" data-v-1a7245e0 data-v-3def6117><img src="/my_blog/avatar.jpg" alt="author-avatar" class="personal-img" data-v-1a7245e0> <h3 class="name" data-v-1a7245e0>
    fh
  </h3> <div class="num" data-v-1a7245e0><div data-v-1a7245e0><h3 data-v-1a7245e0>7</h3> <h6 data-v-1a7245e0>文章</h6></div> <div data-v-1a7245e0><h3 data-v-1a7245e0>3</h3> <h6 data-v-1a7245e0>标签</h6></div></div> <ul class="social-links" data-v-1a7245e0></ul> <hr data-v-1a7245e0></div> <nav class="nav-links"><div class="nav-item"><a href="/my_blog/" class="nav-link"><i class="iconfont reco-home"></i>
  首页
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      文章分类
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/my_blog/categories/other/" class="nav-link"><i class="undefined"></i>
  other
</a></li><li class="dropdown-item"><!----> <a href="/my_blog/categories/font-end/" class="nav-link"><i class="undefined"></i>
  font-end
</a></li></ul></div></div><div class="nav-item"><a href="/my_blog/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  标签
</a></div><div class="nav-item"><a href="/my_blog/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  时间轴
</a></div><div class="nav-item"><a href="/my_blog/docs/theme-reco/" class="nav-link router-link-active"><i class="iconfont reco-message"></i>
  文章列表
</a></div> <!----></nav> <ul class="sidebar-links"><li><a href="/my_blog/" aria-current="page" class="sidebar-link">Home</a></li><li><a href="/my_blog/docs/theme-reco/Vue.html" class="sidebar-link">Vue</a></li><li><a href="/my_blog/docs/theme-reco/css3.html" class="sidebar-link">css3</a></li><li><a href="/my_blog/docs/theme-reco/jQuery.html" class="sidebar-link">jQuery</a></li><li><a href="/my_blog/docs/theme-reco/someKnowledge.html" class="sidebar-link">someKnowledge</a></li><li><a href="/my_blog/docs/theme-reco/mobile.html" aria-current="page" class="active sidebar-link">移动端</a></li></ul> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-70a509e9 data-v-3def6117><h3 class="title" data-v-70a509e9 data-v-70a509e9>移动端</h3> <!----> <label id="box" class="inputBox" data-v-70a509e9 data-v-70a509e9><input type="password" value="" data-v-70a509e9> <span data-v-70a509e9>Konck! Knock!</span> <button data-v-70a509e9>OK</button></label> <div class="footer" data-v-70a509e9 data-v-70a509e9><span data-v-70a509e9><i class="iconfont reco-theme" data-v-70a509e9></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-70a509e9>vuePress-theme-reco</a></span> <span data-v-70a509e9><i class="iconfont reco-copyright" data-v-70a509e9></i> <a data-v-70a509e9><span data-v-70a509e9>fh</span>
            
          <!---->
          2021
        </a></span></div></div> <div data-v-3def6117><main class="page" style="padding-right:0;"><section><div class="page-title"><h1 class="title">移动端</h1> <div data-v-71eee331><i class="iconfont reco-account" data-v-71eee331><span data-v-71eee331>fh</span></i> <i class="iconfont reco-date" data-v-71eee331><span data-v-71eee331>2021/8/18</span></i> <!----> <i class="tags iconfont reco-tag" data-v-71eee331><span class="tag-item" data-v-71eee331>移动端</span></i></div></div> <div class="theme-reco-content content__default"><h5 id="移动端需要兼容的浏览器"><a href="#移动端需要兼容的浏览器" class="header-anchor">#</a> 移动端需要兼容的浏览器</h5> <p>iOS  和  安卓
苹果  -  华为等安卓机
Safari - 各种浏览器
没有 IE   火狐
兼容 Webkit 内核即可
手机最小宽度  320px  iPhone 4-5s</p> <h5 id="弹性盒子布局"><a href="#弹性盒子布局" class="header-anchor">#</a> 弹性盒子布局</h5> <p>display:-webkit-box;
display:flex;
这两个是一样的   是要告诉div你是一个盒子
-webkit-box-orient:horizontal;  告诉盒子你要横着码
-webkit-box-orient:vertical;  告诉盒子你要竖着码</p> <p>接下来要给子集
-webkit-box-flex:1  告诉盒子你要占父级几份</p> <p>flex在计算宽度/高度的时候会减去margin padding border等值</p> <p>如果子元素没有flex  只有宽度/高度的时候  先用父级的宽度/高度 - 没有flex的元素的宽度/高度  再平均分配flex的份数</p> <p>如果分不开了，最后一个元素会多拿一些   （如33.3和33.4这样的情况）</p> <p>弹性布局只适用于一层  不继承</p> <p>一种布局方式就够了  尽量不使用多种布局方式混合</p> <p>flex 只支持块状元素</p> <h5 id="判断移动端方法"><a href="#判断移动端方法" class="header-anchor">#</a> 判断移动端方法</h5> <p>navigator.userAgent  判断这个变量的字符串中有没有 Mobile</p> <h5 id="响应式-移动端-pc端的一个终极解决方案"><a href="#响应式-移动端-pc端的一个终极解决方案" class="header-anchor">#</a> 响应式 - 移动端+pc端的一个终极解决方案</h5> <p>媒体查询
媒体查询判断横屏
@media all and (orientation : landscape){}
媒体查询判断竖屏
@media all and (orientation : portrait){}
媒体查询判断宽度在600px之内
@media screen and (max-width:600px){}
媒体查询判断宽度在600px-800px之间
@media screen and (min-width:600px) and (max-width:800px){}
媒体查询判断宽度大于800px
@media screen and (min-width:800px)</p> <h4 id="rem"><a href="#rem" class="header-anchor">#</a> rem</h4> <p>rem = px
rem * html.fontsize</p> <p>常用 16*20计算</p> <p>chrome 最小字体是12px<br>
Chrome 默认字体是16px</p> <div class="language- line-numbers-mode"><pre class="language-text"><code>(function(win){
    var ratio,scaleValue,renderTime,
    document=window.document,
    docElem=document.documentElement,
    vpm=document.querySelector('meta[name=&quot;viewport&quot;]');
    if(vpm){
        var tempArray=vpm.getAttribute(&quot;content&quot;).match(/initial\-scale=([&quot;']?)([\d\.]+)\1?/);
        if(tempArray){
            scaleValue=parseFloat(tempArray[2]);
            ratio=parseInt(1/scaleValue);
        }
    }else{
        vpm=document.createElement(&quot;meta&quot;);
        vpm.setAttribute(&quot;name&quot;,&quot;viewport&quot;);
        vpm.setAttribute(&quot;content&quot;,&quot;width=device-width,initial-scale=1,user-scalable=no,minimal-ui&quot;);
        docElem.firstElementChild.appendChild(vpm);
    }

    win.addEventListener(&quot;resize&quot;,function(){
        clearTimeout(renderTime);
        renderTime=setTimeout(initPage,300);
    },false);

    win.addEventListener(&quot;pageshow&quot;, function(e) {
        e.persisted &amp;&amp; (clearTimeout(renderTime),renderTime=setTimeout(initPage,300));
    }, false);

    &quot;complete&quot;===document.readyState?document.body.style.fontSize =12*ratio+&quot;px&quot;:
            document.addEventListener(&quot;DOMContentLoaded&quot;,function(){
                document.body.style.fontSize =12*ratio+&quot;px&quot;;
            },false);
    initPage();
    function initPage(){
        var htmlWidth=docElem.getBoundingClientRect().width;
        if(htmlWidth&gt;640) htmlWidth=640;
        htmlWidth/ratio&gt;640 &amp;&amp; (htmlWidth=640*ratio);
        win.rem=htmlWidth/16;
        docElem.style.fontSize=win.rem+&quot;px&quot;;
    }
})(window);
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br><span class="line-number">23</span><br><span class="line-number">24</span><br><span class="line-number">25</span><br><span class="line-number">26</span><br><span class="line-number">27</span><br><span class="line-number">28</span><br><span class="line-number">29</span><br><span class="line-number">30</span><br><span class="line-number">31</span><br><span class="line-number">32</span><br><span class="line-number">33</span><br><span class="line-number">34</span><br><span class="line-number">35</span><br><span class="line-number">36</span><br><span class="line-number">37</span><br><span class="line-number">38</span><br><span class="line-number">39</span><br><span class="line-number">40</span><br></div></div><p>calc css中计算
width=device-width 宽度是设备的宽度
user-scalable=0 用户不允许缩放
initial-scale=1.0, maximum-scale=1.0
最大最小都是1.0</p> <h4 id="localstorage"><a href="#localstorage" class="header-anchor">#</a> localstorage</h4> <p>可以将键值对储存到本地</p> <h4 id="百度地图"><a href="#百度地图" class="header-anchor">#</a> 百度地图</h4> <p>http://lbsyun.baidu.com</p> <h4 id="zepto"><a href="#zepto" class="header-anchor">#</a> zepto</h4> <p>移动端框架  被誉为移动端的jquery
api 几乎和jquery一模一样  但是不兼容低级浏览器</p> <p>pc端拥有的事件：
click：点击事件
onmousedown：点下鼠标
onmouseup：弹起鼠标
onmouseover：鼠标移入
onmouseout：鼠标移出
onmouseenter：鼠标进入
onmouseleave:鼠标离开
onmousemove:鼠标移动
dbclick：鼠标双击
keydown：键盘按下
keyup：键盘弹起
onfocus：得到焦点
onblur：失去焦点
onresize：窗口变化
onload：加载完成
oninput:正在输入
onchange：监听变化
onsubmit：
onreset:
onscroll:</p> <p>touchstart:触摸开始
touchmove:触摸移动
touchend：触摸结束</p> <p>Math.floor 向下取整
Math.abs 没有负数 如果是负数就变成负数
Math.PI 圆周率</p></div></section> <footer class="page-edit"><!----> <div class="last-updated"><span class="prefix">最后更新时间: </span> <span class="time">2021/9/17 下午4:58:22</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev"><a href="/my_blog/docs/theme-reco/someKnowledge.html" class="prev">
            someKnowledge
          </a></span> <!----></p></div> <div class="comments-wrapper"><!----></div> <ul class="side-bar sub-sidebar-wrapper" style="width:0;" data-v-65c007c6></ul></main> <!----></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-a008c6ba data-v-a008c6ba><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-a008c6ba><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-a008c6ba></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-a008c6ba></path></svg></div><canvas id="vuepress-canvas-cursor"></canvas></div></div>
    <script src="/my_blog/assets/js/app.cff69041.js" defer></script><script src="/my_blog/assets/js/3.7a043b16.js" defer></script><script src="/my_blog/assets/js/1.c06040f4.js" defer></script><script src="/my_blog/assets/js/16.a086f842.js" defer></script>
  </body>
</html>
